var QualitiyArtificialDetails = {//质量管理管理初始化
    id: "QualitiyArtificialDetailsTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

QualitiyArtificialDetails.initColumn = function () {//初始化表格的列
    var columns = [
        {title: 'id', field: 'id1', visible: false, align: 'center', valign: 'middle'},
        {title: '图片类型', field: 'photoType', align: 'center', valign: 'middle', width: 40,
            formatter: function (value, row, index) {
                if (value == "1") {return "术前"} else if (value == "2") {return "术中"} else if (value == "3")  {return "术后"}else {return "总分"}
            }
        },
        {title: 'B1', field: 'a1', align: 'center', valign: 'middle', width: 20},
        {title: 'B2', field: 'b1', align: 'center', valign: 'middle', width: 20},
        {title: 'B3', field: 'c1', align: 'center', valign: 'middle', width: 20},
        {title: 'B4', field: 'd1', align: 'center', valign: 'middle', width: 20},
        {title: 'B5', field: 'e1', align: 'center', valign: 'middle', width: 20},
        {title: 'B6', field: 'f1', align: 'center', valign: 'middle', width: 20},
        {title: 'B7', field: 'g1', align: 'center', valign: 'middle', width: 20},
        {title: '得分', field: 'score1', align: 'center', valign: 'middle', width: 20},
        {title: '时间', field: 'updateTime', align: 'center', valign: 'middle', width: 50}
    ];
    return columns
};

QualitiyArtificialDetails.check = function () { // 检查是否选中
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        QualitiyArtificialDetails.seItem = selected[0];
        return true;
    }
};

QualitiyArtificialDetails.close = function () {
    parent.layer.close(parent.layer.getFrameIndex(window.name));
};

QualitiyArtificialDetails.additionalData1 = function () {
    var aValue = 0 , bValue = 0 , cValue = 0;
    var data = $('#QualitiyArtificialDetailsTable').bootstrapTable('getData', true);
    for(var i = 0 ; i < data.length ; i++){
        aValue += parseFloat(data[i].a1);
        bValue += parseFloat(data[i].b1);
        cValue += parseFloat(data[i].c1);
    }
    var a1 = (aValue/3).toFixed(2) ,
        b1 = (bValue/3).toFixed(2) ,
        c1 = (cValue/3).toFixed(2) ,
        d1 = parseFloat(data[1].d1).toFixed(2) ,
        e1 = parseFloat(data[2].e1).toFixed(2) ,
        f1 = parseFloat(data[2].f1).toFixed(2) ,
        g1 = parseFloat(data[2].g1).toFixed(2) ;
    var score1 = parseFloat(a1) + parseFloat(b1) + parseFloat(c1) + parseFloat(d1) + parseFloat(e1) + parseFloat(f1) + parseFloat(g1);
    var arr = [{id1:'',photoType:'0',a1:a1,b1:b1,c1:c1,d1:d1,e1:e1,f1:f1,g1:g1,score1:score1.toFixed(2),updateTime:''}];
    $('#QualitiyArtificialDetailsTable').bootstrapTable('append', arr);
};

$(function () {
    var num = $("#numValue").val();
    var defaultColunms = QualitiyArtificialDetails.initColumn();
    var artificialTable = new BSTable(QualitiyArtificialDetails.id, "/doctorLooked/getIntelligentScoreDetailsList/" + num , defaultColunms);
    artificialTable.setPaginationType("server");
    QualitiyArtificialDetails.table = artificialTable.init();
    $('#QualitiyArtificialDetailsTable').bootstrapTable('resetView', {height: $(window).height() - 210});
    $(document).on("load-success.bs.table", function() {QualitiyArtificialDetails.additionalData1();})
});